/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Administrateur
 */
@Entity
@Table(name = "element_commande")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ElementCommande.findAll", query = "SELECT e FROM ElementCommande e"),
    @NamedQuery(name = "ElementCommande.findByIdelementCommande", query = "SELECT e FROM ElementCommande e WHERE e.idelementCommande = :idelementCommande"),
    @NamedQuery(name = "ElementCommande.findByQuantite", query = "SELECT e FROM ElementCommande e WHERE e.quantite = :quantite"),
    @NamedQuery(name = "ElementCommande.findByPrixUnite", query = "SELECT e FROM ElementCommande e WHERE e.prixUnite = :prixUnite")})
public class ElementCommande implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "idelement_commande")
    private Integer idelementCommande;
    @Basic(optional = false)
    @NotNull
    @Column(name = "quantite")
    private int quantite;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "prix_unite")
    private Double prixUnite;
    @JoinColumn(name = "idProduit", referencedColumnName = "idproduit")
    @ManyToOne(optional = false)
    private Produit idProduit;
    @JoinColumn(name = "idCommande", referencedColumnName = "idcommande")
    @ManyToOne(optional = false)
    private Commande idCommande;

    public ElementCommande() {
    }

    public ElementCommande(Integer idelementCommande) {
        this.idelementCommande = idelementCommande;
    }

    public ElementCommande(Integer idelementCommande, int quantite) {
        this.idelementCommande = idelementCommande;
        this.quantite = quantite;
    }

    public Integer getIdelementCommande() {
        return idelementCommande;
    }

    public void setIdelementCommande(Integer idelementCommande) {
        this.idelementCommande = idelementCommande;
    }

    public int getQuantite() {
        return quantite;
    }

    public void setQuantite(int quantite) {
        this.quantite = quantite;
    }

    public Double getPrixUnite() {
        return prixUnite;
    }

    public void setPrixUnite(Double prixUnite) {
        this.prixUnite = prixUnite;
    }

    public Produit getIdProduit() {
        return idProduit;
    }

    public void setIdProduit(Produit idProduit) {
        this.idProduit = idProduit;
    }

    public Commande getIdCommande() {
        return idCommande;
    }

    public void setIdCommande(Commande idCommande) {
        this.idCommande = idCommande;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idelementCommande != null ? idelementCommande.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ElementCommande)) {
            return false;
        }
        ElementCommande other = (ElementCommande) object;
        if ((this.idelementCommande == null && other.idelementCommande != null) || (this.idelementCommande != null && !this.idelementCommande.equals(other.idelementCommande))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.ElementCommande[ idelementCommande=" + idelementCommande + " ]";
    }
    
}
